<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div class="page">
    <h3 class="big-title">账户转账</h3>
    <form action="" class="page-container">
        <div class="inputs clearfloat">
            <label for="optionHtml" class="">账户数额</label>
            <select class="select" id="optionHtml" name="accountId">
                <script id="optionScript" type="text/html">
                    {{each data item index}}
                         <option value="{{item.id}}">{{item.accountType | accountType}}：{{item.amountNum}}</option>
                    {{/each}}
                </script>
            </select>
        </div>
        <div class="inputs clearfloat">
            <label for="amount" class="">转账金额</label>
            <input type="text" name="amount" id="amount">
        </div>
        <div class="inputs clearfloat">
            <label for="phoneNum" class="">转入好友</label>
            <input type="text" name="phoneNum" id="phoneNum" />
        </div>

        <div class="edit">
            <input type="button" class="buttons" value="确认转账" onclick="submitTrans()">

        </div>
    </form>

</div>
<script src="js/jquery-1.8.3.min.js"></script>
<script src="js/layer/layer.js"></script>
<script src="js/moment-2.2.1.js"></script>
<script src="js/template-web.js"></script>
<script src="js/jdgj/config.js"></script>
<script >
    var userId = config.getUserId();
    var pageNo = pageNo | 1;
    $.get(config.baseUrl + "account/quaryAccountType.json",{userId: userId, type:2}, function(result){
        if (result.status == 200) {
            var html = template("optionScript", result);
            $("#optionHtml").html(html);
        }
    });
    // 加载账户信息信息
    template.defaults.imports.accountType = function(value){
        return config.accountType(value);
    };
    // 提交转账申请
    function submitTrans() {
        var accountId = $("#optionHtml").val();
        var phoneNum = $("#phoneNum").val();
        var amount = $("#amount").val();
        if(accountId=='' || phoneNum=='' || amount=='') {
            return false;
        }
        $.post(config.baseUrl+"/account/transferToFriend.json",{accountId:accountId,
        phoneNum:phoneNum, amount: amount, payType:0
        },function(result){
            console.info(result)
            debugger;
            if(result.status==200) {
                layer.alert("转账成功");
            } else {
                layer.alert(result.msg);
            }
        },'json');
    }

</script>
</body>
</html>